/*
 * @Author: 亚亚
 */
/*
 * @Author: 亚亚
 */
/*
 * @Author: 亚亚
 */
import { App, createApp } from 'vue'
import { createPinia } from 'pinia'

import AppPage from './App.vue'
import router from './router'
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';

// import '@unocss/reset/tailwind.css'
import 'uno.css'
import './style/main.css'
import {useTable} from './useTable'
import lodash from './utils/lodash'

// const app = createApp(App)
// app.use(createPinia())
// app.use(router)

// app.mount('#app')

let root: App;

function render(props: any) {
  const { container } = props;
  root = createApp(AppPage)
  const c = container
    ? container.querySelector("#micro-app")
    : document.getElementById("micro-app");

  root.use(createPinia())
  root.use(router)
  root.use(useTable)
  lodash(root)
  root.mount(c)
}

renderWithQiankun({
  mount(props) {
    console.log("vue3sub mount-------------------------",props);
    render(props);
  },
  bootstrap() {
    console.log("bootstrap-------------------------");
  },
  unmount(props: any) {
    console.log("vue3sub unmount-------------------------");
    root.unmount();
  },
  update(props: any) {
    console.log("vue3sub update-------------------------");
    console.log(props)
  },
});

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render({});
}
